﻿/***************************
 * 数据访问层
 * 小区的状况添加
 * Author：JXL
 ***************************/ 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using IDAL;
using System.Data.SqlClient;
using System.Configuration;
using HouseCommon;


namespace DAL
{
    public class LocationDAL : BaseDAL, ILocationDAL
    {

        protected override string tablename
        {
            get { return "Location"; }
        }

        protected override Dictionary<string, bool> pkname
        {
            get
            {
                Dictionary<string, bool> id = new Dictionary<string, bool>();

                id.Add("location_id", true);
                return id;
            }
        }

        /// <summary>
        /// 小区状况数据的添加
        /// </summary>
        /// <param name="mo"></param>
        /// <returns></returns>
        public int LocationAdd(Location mo)
        {
            using (SqlConnection conn = new SqlConnection(Common.conn))
            {
                conn.Open();
                string sql = string.Format("insert into Location(ProjectNumber,Location_East,Location_West,Location_North,Location_South,Location_Position,Location_Traffic,Location_Convenient,Location_Humanity,Location_Quality,Location_Community,Location_Mature,Location_Facilities,Location_Degree,Location_Supporting,Location_Explain,Location_CreateTime,Location_CreatePeople)values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',GETDATE(),'0')", mo.projectNumber, mo.location_East, mo.location_West, mo.location_North, mo.location_South, mo.location_Position, mo.location_Traffic, mo.location_Convenient, mo.location_Humanity, mo.location_Quality, mo.location_Community, mo.location_Mature, mo.location_Facilities, mo.location_Degree, mo.location_Supporting, mo.location_Explain);
                SqlCommand cmd = new SqlCommand(sql, conn);
                int i = cmd.ExecuteNonQuery();
                conn.Close();
                return i;
            }
        }
    }
}

